import {request} from "../request";
import {utils} from "../../common/utils";

//1.获取所有部门的信息
export function getDeptList(companyId) {
    return request({
        url: '/sys/dept/query',
        method: 'get',
        params:{
            companyId
        }
    })
}

//2.添加部门
export function addDept({companyId, deptName, address, parentId, enabled}) {
    return request({
        url: '/sys/dept/add',
        method: 'post',
        data: {companyId, deptName, address, parentId, enabled}
    })
}

//3.修改部门信息
export function updateDept({id, companyId, deptName, address, parentId, enabled,}){
    return request({
        url: '/sys/dept/update',
        method: 'put',
        data: {
            id, companyId, deptName, address, parentId, enabled
        }
    })
}

//4.删除部门
export function deleteDept(ids){
    let strUtl = utils.joinArrayReqParam(ids,'ids');
    return request({
        url: '/sys/dept/delete' + strUtl,
        method: 'delete'
    })
}

//5.获取部门选项信息
export function getDeptOptions(companyId){
    return request({
        url: '/sys/dept/options',
        method: 'get',
        params:{
            companyId
        }
    })
}

//6、判断同公司下是否还有相同名称的部门
export function hasSomeDeptName({id,deptName,companyId}){
    return request({
        url: '/sys/dept/has-some-deptName',
        params:{
            id,
            deptName,
            companyId
        }
    })
}